#include <iostream>
#include <deque>
#include <vector>
#include <algorithm>
using namespace std;

void test_op1()
{
	srand((unsigned int)time(0));
	const int N = 1000000;
	vector<int> v1;
	deque<int> dq1;

	for (size_t i = 0; i < N; i++)
	{
		int e = rand();
		v1.push_back(e);
		dq1.push_back(e);
	}

	size_t begin1 = clock();
	sort(v1.begin(), v1.end());
	size_t end1 = clock();

	size_t begin2 = clock();
	sort(dq1.begin(), dq1.end());
	size_t end2 = clock();

	cout << "vector sort: " << end1 - begin1 << endl;
	cout << "deque sort: " << end2 - begin2 << endl;
}

void test_op2()
{
	srand((unsigned int)time(0));
	const int N = 1000000;
	deque<int> dq1;
	deque<int> dq2;

	for (size_t i = 0; i < N; i++)
	{
		int e = rand();
		dq1.push_back(e);
		dq2.push_back(e);
	}

	size_t begin1 = clock();
	sort(dq1.begin(), dq1.end());
	size_t end1 = clock();

	size_t begin2 = clock();
	vector<int> v;
	v.assign(dq2.begin(), dq2.end());
	sort(v.begin(), v.end());
	dq2.assign(v.begin(), v.end());
	size_t end2 = clock();

	cout << "deque sort: " << end1 - begin1 << endl;
	cout << "deque copy vector sort,vector back: " << end2 - begin2 << endl;
}

int main()
{
	test_op1();
	test_op2();

	return 0;
}



//int main()
//{
//	deque<int> dq{ 1,2,3,4,5,6,7,8,9 };
//	auto it1 = dq.begin();
//	while (it1 != dq.end())
//	{
//		cout << *it1 << " ";
//		++it1;
//	}
//	cout << endl;
//
//	return 0;
//}